<clr-modal [(clrModalOpen)]="modalOpened">
  <h3 class="modal-title">{{title}}</h3>

  <div class="clr-col-lg-12 clr-col-md-12 clr-col-sm-12 clr-col-xs-12" class="modal-body">
    <form #apiKeyForm="ngForm" clrForm clrLayout="horizontal">
      <section class="form-block">
        <clr-input-container>
          <label class="required">{{'TITLE.NAME' | translate}}</label>
          <input clrInput [(ngModel)]="apiKey.name" type="text" name="name" required id="name" [placeholder]="'PLACEHOLDER.NAME' | translate"
            size="45">
        </clr-input-container>
        <clr-select-container>
          <label class="required">{{'TITLE.ROLE' | translate}}</label>
          <select clrSelect id="role" [(ngModel)]="apiKey.group.id" required name="role">
            <!--这是一个坑，如果使用value获取到的是string，使用ngValue获取到的是model本身类型-->
            <option *ngFor="let group of groups" [ngValue]="group.id">{{group.name}}
            </option>
          </select>
        </clr-select-container>
        <clr-input-container>
          <label class="required">{{'TITLE.EXPIRE_TIME' | translate}}</label>
          <input  clrInput [(ngModel)]="apiKey.expireIn" type="number" required name="expire_in" id="expire_in"
            [placeholder]="'PLACEHOLDER.EXPIRE_TIME' | translate" size="45">
        </clr-input-container>
        <clr-textarea-container>
          <label>{{'TITLE.DESCRIPTION' | translate}}</label>
          <textarea clrTextarea type="text" [(ngModel)]="apiKey.description" name="description" id="description" size="45"></textarea>
        </clr-textarea-container>
        <div class="modal-footer">

          <button type="button" class="btn btn-outline" (click)="onCancel()">{{'BUTTON.CANCEL' | translate}}</button>
          <button type="button" class="btn btn-primary" [disabled]="!isValid"
                  (click)="onSubmit()">{{'BUTTON.SUBMIT' | translate}}</button>
        </div>
      </section>
    </form>
  </div>
</clr-modal>
